package com.example.design.ddd.practice2.domain.order.entity;

import com.example.design.ddd.practice2.domain.order.valueobject.Money;
import java.math.BigDecimal;

/**
 * 实体 - 订单项
 */
public class OrderItem {
    /**
     * 商品
     */
    private String productId;
    private String productName;
    /**
     * 商品价格
     */
    private Money price;
    /**
     * 数量
     */
    private int quantity;

    public Money total() {
        return new Money(
            price.getAmount().multiply(BigDecimal.valueOf(quantity)),
            price.getCurrency()
        );
    }


}